import dayjs from "dayjs";

export default {
  // 基本路径设置
  setBaseUrl() {
    let baseUrl = "";
    if (process.env.NODE_ENV === "development") {
      baseUrl = "/";
    } else {
      // 你的 API 地址
      baseUrl = "";
    }
    return baseUrl;
  },
  // DataV-charts 全局默认设置
  chartsDefaultOptions: {
    xAxisParam: {
      axisLine: {
        style: {
          stroke: "#ccc",
        },
      },
      axisLabel: {
        style: {
          fill: "#ccc",
        },
      },
      axisTick: {
        show: false,
      },
    },
    yAxisParam: {
      splitLine: {
        show: true,
      },
      axisLine: {
        style: {
          stroke: "#ccc",
        },
      },
      axisLabel: {
        style: {
          fill: "#ff0",
        },
      },
      axisTick: {
        show: true,
      },
    },
  },
  // dayjs 格式化时间
  formatDate(value) {
    // 星期值的转换
    let _day = dayjs().day();
    switch (_day) {
      case 1:
        _day = "一";
        break;
      case 2:
        _day = "二";
        break;
      case 3:
        _day = "三";
        break;
      case 4:
        _day = "四";
        break;
      case 5:
        _day = "五";
        break;
      case 6:
        _day = "六";
        break;
      case 0:
        _day = "日";
        break;
    }
    let _date =
      dayjs(value).format("YYYY年MM月DD日") +
      " " +
      "星期" +
      _day +
      " " +
      dayjs(value).format("HH:mm:ss");
    return _date;
  },
};
